# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Fabian Bornschein <fabiscafe-cat-mailbox-dog-org>

pkgname=gnome-builder
pkgver=44.2
pkgrel=2
pkgdesc="An IDE for writing GNOME-based software"
url="https://wiki.gnome.org/Apps/Builder"
arch=(x86_64)
license=(GPL3)
depends=(
  autoconf-archive
  clang
  cmark
  ctags
  d-spy
  desktop-file-utils
  devhelp
  editorconfig-core-c
  flatpak-builder
  gjs
  glib2
  gtksourceview5
  jsonrpc-glib
  libadwaita
  libdex
  libgit2-glib
  libpanel
  libpeas
  libportal-gtk4
  meson
  python-gobject
  python-lxml
  python-sphinx
  sysprof
  template-glib
  vala
  vte4
  webkitgtk-6.0
)
makedepends=(
  appstream-glib
  git
  gobject-introspection
  llvm
  mm-common
  python-lsp-server
  python-sphinx_rtd_theme
  yelp-tools
)
checkdepends=(weston)
_commit=abc6bbd213df29f156514e40d3f9cdfee57f8c01  # tags/44.2^0
source=("git+https://gitlab.gnome.org/GNOME/gnome-builder.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  local meson_options=(
    -D help=true
  )

  arch-meson $pkgname build "${meson_options[@]}"
  meson compile -C build
}

check() (
  export XDG_RUNTIME_DIR="$PWD/runtime-dir" WAYLAND_DISPLAY=wayland-5

  mkdir -p -m 700 "$XDG_RUNTIME_DIR"
  weston --backend=headless-backend.so --socket=$WAYLAND_DISPLAY --idle-time=0 &
  _w=$!

  trap "kill $_w; wait" EXIT

  dbus-run-session meson test -C build --print-errorlogs
)

package() {
  depends+=(libgit2.so)
  optdepends=(
    'bash-language-server: Shell code assistance'
    'python-lsp-server: Python code assistance'
  )
  groups=(gnome-extra)

  meson install -C build --destdir "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
